package myhomework;

import java.util.Arrays;

public class Work6 {
    public static void main(String[] args) {


        String[] elem=new  String[]{"abc","123","123","123","666","777"};
        String target="123";
        int i=0;
        int count=0;
        while(i<elem.length){
            if(target.equals(elem[i])){
                i++;
                count++;
            }else{
                i++;
            }

        }
        String[] newElem=new String[elem.length-count];
        i=0;int j=0;
        while (i<elem.length){
            if(target.equals(elem[i])){
                i++;
                continue;
            }
            newElem[j]=elem[i];
            i++;
            j++;
        }
        System.out.println(count);
        System.out.println(Arrays.toString(newElem));
    }
}
